Some computer program environments provide runtime support for one or more dynamic behaviors. Some dynamic behaviors include dynamic dispatch, reflection, downcasting, self-modifying code, dynamic type-checking, and/or just-in-time compilation. Dynamic dispatch involves selecting at runtime which implementation of a polymorphic method (or function) is called from a given invocation. Type introspection involves a running program examining its own values, metadata, properties, and/or functions; reflection goes further because it involves a running program altering its own values, metadata, properties, and/or functions. Downcasting or type refinement involves casting a reference of a base class to a derived class of the base class. Self-modifying involves a program modifying its own code at runtime. Dynamic type-checking involves verifying type-safety of a program while the program is running. Just-in-time (JIT) compilation involves compiling code for a program while the program is running; the compiled code may be native code or it may be higher-level code which is then interpreted, for example. Some dynamic programming languages execute program behaviors at runtime that are performed instead during compilation for static programming languages, e.g., extending a program by adding new code, extending objects and their definitions, and/or modifying a type system.
Balancing dynamic and static features in an environment can be challenging. Balance is sometimes possible, in the sense that a program with dynamic behaviors may also have features such as static type-checking, static compilation, and/or creation of an executable application all of whose components have been identified during an ahead-of-time compilation before the application begins execution. Dynamic features can provide flexibility and power which is missing from familiar statically compiled programs. In many situations, however, static compilation of a program permits a smaller and less complex runtime, and provides greater certainty about the program's behavior during testing and/or when checking the program for malware. Accordingly, new ways to balance static and dynamic functionality can be useful and concrete advances in computer programming.